<?php
// SomeryC, a webcomic script by Zachary Weston Lewis
// Based on Somery by Robin de Graaf
// Copyright 2005-2006
// SomeryC is distributed under the Artistic License (see LICENSE.txt)
//
// 0.2.5-UPDATE.PHP > 08-31-2006

extract($_POST);
extract($_GET);

if (!$step) {
	echo "Click <a href=\"0.2.5-update.php?step=1\">here</a> to update your someryC database to 0.2.5.";
	exit;
}

include("config.php");
mysql_connect($sqlhost, $sqluser, $sqlpass);
mysql_select_db($sqldb);

// Update articles
$query = "ALTER TABLE ".$prefix."articles MODIFY title varchar(255)";
$q = mysql_query($query) or die ("<p style=\"color:#cc0000;\">Updating articles table for SomeryC 0.2.5 failed.</p>Host: $sqlhost / User: $sqluser / Database: $sqldb");

// Rename categories to chapters
$query = "RENAME TABLE ".$prefix."categories TO ".$prefix."chapters";
$q = mysql_query($query) or die ("<p style=\"color:#cc0000;\">Renaming categories table for SomeryC 0.2.5 failed.</p>Host: $sqlhost / User: $sqluser / Database: $sqldb");

// Update chapters
$query = "ALTER TABLE ".$prefix."chapters CHANGE category chapter varchar(255)";
$q = mysql_query($query) or die ("<p style=\"color:#cc0000;\">Updating chapters table for SomeryC 0.2.5 failed.</p>Host: $sqlhost / User: $sqluser / Database: $sqldb");

// Update comics
$query = "ALTER TABLE ".$prefix."comics CHANGE category chapter varchar(255)";
$q = mysql_query($query) or die ("<p style=\"color:#cc0000;\">Updating comics table for SomeryC 0.2.5 failed.</p>Host: $sqlhost / User: $sqluser / Database: $sqldb");

$query = "ALTER TABLE ".$prefix."comics MODIFY	title varchar(255)";
$q = mysql_query($query) or die ("<p style=\"color:#cc0000;\">Updating comics table for SomeryC 0.2.5 failed.</p>Host: $sqlhost / User: $sqluser / Database: $sqldb");

$query = "ALTER TABLE ".$prefix."comics MODIFY	url varchar(255)";
$q = mysql_query($query) or die ("<p style=\"color:#cc0000;\">Updating comics table for SomeryC 0.2.5 failed.</p>Host: $sqlhost / User: $sqluser / Database: $sqldb");

// Update comments
$query = "ALTER TABLE ".$prefix."comments MODIFY	author varchar(255)";
$q = mysql_query($query) or die ("<p style=\"color:#cc0000;\">Updating comments table for SomeryC 0.2.5 failed.</p>Host: $sqlhost / User: $sqluser / Database: $sqldb");

$query = "ALTER TABLE ".$prefix."comments MODIFY	url varchar(255)";
$q = mysql_query($query) or die ("<p style=\"color:#cc0000;\">Updating comments table for SomeryC 0.2.5 failed.</p>Host: $sqlhost / User: $sqluser / Database: $sqldb");

$query = "ALTER TABLE ".$prefix."comments MODIFY	email varchar(255)";
$q = mysql_query($query) or die ("<p style=\"color:#cc0000;\">Updating comments table for SomeryC 0.2.5 failed.</p>Host: $sqlhost / User: $sqluser / Database: $sqldb");
// Add comments IP
$query = "ALTER TABLE ".$prefix."comments ADD COLUMN	ip varchar(16) AFTER time";
$q = mysql_query($query) or die ("<p style=\"color:#cc0000;\">Adding to comments table for SomeryC 0.2.5 failed.</p>Host: $sqlhost / User: $sqluser / Database: $sqldb");

// Update profile
$query = "ALTER TABLE ".$prefix."profile MODIFY	username varchar(255)";
$q = mysql_query($query) or die ("<p style=\"color:#cc0000;\">Updating profile table for SomeryC 0.2.5 failed.</p>Host: $sqlhost / User: $sqluser / Database: $sqldb");

$query = "ALTER TABLE ".$prefix."profile MODIFY	nickname varchar(255)";
$q = mysql_query($query) or die ("<p style=\"color:#cc0000;\">Updating profile table for SomeryC 0.2.5 failed.</p>Host: $sqlhost / User: $sqluser / Database: $sqldb");

$query = "ALTER TABLE ".$prefix."profile MODIFY	firstname varchar(255)";
$q = mysql_query($query) or die ("<p style=\"color:#cc0000;\">Updating profile table for SomeryC 0.2.5 failed.</p>Host: $sqlhost / User: $sqluser / Database: $sqldb");

$query = "ALTER TABLE ".$prefix."profile MODIFY	lastname varchar(255)";
$q = mysql_query($query) or die ("<p style=\"color:#cc0000;\">Updating profile table for SomeryC 0.2.5 failed.</p>Host: $sqlhost / User: $sqluser / Database: $sqldb");

$query = "ALTER TABLE ".$prefix."profile MODIFY	country varchar(255)";
$q = mysql_query($query) or die ("<p style=\"color:#cc0000;\">Updating profile table for SomeryC 0.2.5 failed.</p>Host: $sqlhost / User: $sqluser / Database: $sqldb");

$query = "ALTER TABLE ".$prefix."profile MODIFY	city varchar(255)";
$q = mysql_query($query) or die ("<p style=\"color:#cc0000;\">Updating profile table for SomeryC 0.2.5 failed.</p>Host: $sqlhost / User: $sqluser / Database: $sqldb");

$query = "ALTER TABLE ".$prefix."profile MODIFY	email varchar(255)";
$q = mysql_query($query) or die ("<p style=\"color:#cc0000;\">Updating profile table for SomeryC 0.2.5 failed.</p>Host: $sqlhost / User: $sqluser / Database: $sqldb");

$query = "ALTER TABLE ".$prefix."profile MODIFY	url varchar(255)";
$q = mysql_query($query) or die ("<p style=\"color:#cc0000;\">Updating profile table for SomeryC 0.2.5 failed.</p>Host: $sqlhost / User: $sqluser / Database: $sqldb");

$query = "ALTER TABLE ".$prefix."profile MODIFY	msn varchar(255)";
$q = mysql_query($query) or die ("<p style=\"color:#cc0000;\">Updating profile table for SomeryC 0.2.5 failed.</p>Host: $sqlhost / User: $sqluser / Database: $sqldb");

$query = "ALTER TABLE ".$prefix."profile MODIFY	aim varchar(255)";
$q = mysql_query($query) or die ("<p style=\"color:#cc0000;\">Updating profile table for SomeryC 0.2.5 failed.</p>Host: $sqlhost / User: $sqluser / Database: $sqldb");

$query = "ALTER TABLE ".$prefix."profile MODIFY	yim varchar(255)";
$q = mysql_query($query) or die ("<p style=\"color:#cc0000;\">Updating profile table for SomeryC 0.2.5 failed.</p>Host: $sqlhost / User: $sqluser / Database: $sqldb");

$query = "ALTER TABLE ".$prefix."profile MODIFY	avatar varchar(255)";
$q = mysql_query($query) or die ("<p style=\"color:#cc0000;\">Updating profile table for SomeryC 0.2.5 failed.</p>Host: $sqlhost / User: $sqluser / Database: $sqldb");

// Add getMail
$query = "ALTER TABLE ".$prefix."profile ADD COLUMN	getmail int(11) default '0' AFTER signature";
$q = mysql_query($query) or die ("<p style=\"color:#cc0000;\">Adding to profile table for SomeryC 0.2.5 failed.</p>Host: $sqlhost / User: $sqluser / Database: $sqldb");

// Update settings
$query = "ALTER TABLE ".$prefix."settings MODIFY	skindir varchar(255)";
$q = mysql_query($query) or die ("<p style=\"color:#cc0000;\">Updating settings table for SomeryC 0.2.5 failed.</p>Host: $sqlhost / User: $sqluser / Database: $sqldb");

// Update users
// Update comics
$query = "ALTER TABLE ".$prefix."users MODIFY	password varchar(255)";
$q = mysql_query($query) or die ("<p style=\"color:#cc0000;\">Updating users table for SomeryC 0.2.5 failed.</p>Host: $sqlhost / User: $sqluser / Database: $sqldb");


echo "<p style=\"color:#00A400;\">Success!</p><br />
	Your SomeryC database is updated to 0.2.5! Remove this update script and upload the files (if you haven't done so yet) and log in.";
?>
